<template>
  <view>
    <scroll-view scroll-y style="height: 80px">
      <view v-for="(item, index) in buffer" :key="index">
        {{ item }}
      </view>
    </scroll-view>
  </view>
</template>

<script>
import JavaWebSocket from "../../utils/socket/JavaWebSocket";
import middleWareApi from "../../api/middleWareApi";

export default {
  name: "seg-log-with-socket",
  mixins: [JavaWebSocket],
  data(){
    return {
      buffer: []
    }
  },
  mounted() {
    let url = middleWareApi.VUE_SOCKET_ADDRESS

    // const msgArrive = (res)=>{
    //   this.buffer.unshift(res.data)
    // }
    // this.socketInit(url, null, null, null, msgArrive)

    // 模拟页面跳转导致的两次重新连接bug
    // setTimeout(()=>{
    //   this.wsCloseDefault()
    // }, 2000)

    // 模拟消息传输
    // this.msgSendLoop()
    // for (let i = 0; i < 1000; i++){
    //   let msg = 'count is: ' + i
    //   setTimeout(()=>{
    //     this.sendMsgWithSocket(msg)
    //   }, 1000)
    // }

  }

}
</script>

<style scoped>

</style>
